import platform
import os
import threading
import time

class ProcessApp(object):
    def __init__(self, process_start_path):
        self.__process_start_path = process_start_path  # 例 xcms_zlm -c D:\\bin\\config.json

    def __start_process_thread(self):
        try:
            # logger.info("__start_process_thread(): %s", process_start_path)
            res = os.popen(self.__process_start_path)
            res.read()
        except Exception as e:
            print("__start_process_thread() error: %s" % str(e))

    def start(self):
        t = threading.Thread(target=self.__start_process_thread)
        t.daemon = True
        t.start()

if __name__ == '__main__':

    systemName = platform.system()
    if systemName == "Windows":
        __xcnvs_admin_process_start_path = "xcnvs_admin.exe"
        __xcnvs_fs_process_start_path = "xcnvs_fs.exe"
        __xcnvs_zlm_process_start_path = "xcnvs_zlm.exe -c config.ini"

    else:
        __xcnvs_admin_process_start_path = "./xcnvs_admin"
        __xcnvs_fs_process_start_path = "./xcnvs_fs"
        __xcnvs_zlm_process_start_path = "./xcnvs_zlm -c config.ini"

    __xcnvs_admin = ProcessApp(__xcnvs_admin_process_start_path)
    __xcnvs_fs = ProcessApp(__xcnvs_fs_process_start_path)
    __xcnvs_zlm = ProcessApp(__xcnvs_zlm_process_start_path)

    __xcnvs_admin.start()
    __xcnvs_fs.start()
    __xcnvs_zlm.start()

    while True:
        pass
        time.sleep(10)
